hysop package

Python package dedicated to flow simulation using particular methods on hybrid architectures (MPI-GPU)

class hysop.Box(length=None, origin=None, dim=None, lboundaries=None, rboundaries=None, **kwds)[source]

Bases: BoxView, Domain

Box-shaped domain description.

Initialize this object. If self._initialized was already set to True, raise a RuntimeError. Else, set self._initialized to True.

static __new__(cls, length=None, origin=None, dim=None, lboundaries=None, rboundaries=None, **kwds)[source]

Create or get an existing Box from a dimension, length and origin with specified left and right boundary conditions.

Parameters:
  • length (array like of float, optional) – Box sides lengthes. Default = [1.0, …]

  • origin (array like of float, optional) – Position of the lowest point of the box. Default [0.0, …]

  • dim (int, optional) – Dimension of the box.

  • lboundaries (array_like of BoxBoundaryCondition) – Left boundary conditions.

  • rboundaries (array_like of BoxBoundaryCondition) – Right boundary conditions.

dim

Dimension of the box.

Type:

int

length

Box sides lengthes.

Type:

np.ndarray of HYSOP_REAL

origin

Position of the lowest point of the box.

Type:

np.ndarray of HYSOP_REAL

end

Position of the greatest point of the box.

Type:

np.ndarray of HYSOP_REAL

lboundaries

Left boundary conditions.

Type:

np.ndarray of BoxBoundaryCondition

rboundaries

Right boundary conditions.

Type:

np.ndarray of BoxBoundaryCondition

boundaries

Left and right boundary conditions as a tuple.

Type:

tuple of np.ndarray of BoxBoundaryCondition

periodicity

Numpy array mask, True is axis is periodic, else False.

Type:

np.ndarray of bool

view(topology_state)[source]

Return a view of this domain altered by some topology_state.

class hysop.BufferParameter(shape=None, dtype=<class 'numpy.float64'>, initial_value=None, symbol=None, **kwds)[source]

Bases: Parameter

A buffer parameter is np.ndarray with specific shape and dtype. A parameter is a value that may change as simulation advances.

Initialize a TaggedObject with a tag prefix/postfix/formatter, all optional.

property ctype

Get the data type of the discrete field as a C type.

property dtype

Get parameter dtype.

iterviews()[source]

Iterate over all parameters views to yield scalarparameters.

long_description()[source]

Return a long description of this parameter as a string.

property ndim

Get parameter ndim.

reallocate_buffer(shape, dtype, initial_value=None, symbol=None)[source]
property shape

Get parameter shape.

short_description()[source]

Return a short description of this parameter as a string.

property size

Get parameter size.

class hysop.CartesianDiscretization(resolution, ghosts=None, lboundaries=None, rboundaries=None, default_boundaries=False)[source]

Bases: CartesianDiscretization

A struct to handle discretization parameters: - a resolution (either a list of int or a numpy array of int)

resolution is GRID_RESOLUTION. GLOBAL_RESOLUTION is GRID_RESOLUTION + PERIODICITY.

  • number of points in the ghost-layer. One value per direction, list

    or array. Default = None (ie. no ghosts).

  • global boundary conditions that should be prescribed on the left and the

    right of the box shaped domain for each axis. Defaults to periodic boundary conditions everywhere.

Create new instance of CartesianDiscretization(resolution, ghosts, lboundaries, rboundaries)

property boundaries

Left and right boundary conditions as a tuple.

property global_resolution

Logical grid resolution (grid_resolution + periodicity). Can only be fetched if boundaries have been specified.

property grid_resolution

Effective grid resolution given by user.

property periodicity
class hysop.CartesianTopology(domain, discretization, mpi_params=None, cart_dim=None, cart_shape=None, is_periodic=None, cutdirs=None, mesh=None, cartesian_topology=None, cl_env=None, **kwds)[source]

Bases: CartesianTopologyView, Topology

CartesianTopology topologies defined on cartesian meshes which communicates accross processes through a MPI CartesianTopology communicator.

Initialize this object. If self._initialized was already set to True, raise a RuntimeError. Else, set self._initialized to True.

static __new__(cls, domain, discretization, mpi_params=None, cart_dim=None, cart_shape=None, is_periodic=None, cutdirs=None, mesh=None, cartesian_topology=None, cl_env=None, **kwds)[source]

Initializes or get an existing CartesianTopology topology.

Parameters:
  • domain (Box) – The box geometry on which the cartesian topology is defined.

  • discretization (CartesianDiscretization) – Description of the global space discretization of the box (resolution, ghosts, and boundary conditions).

  • mpi_params (MPIParams, optional) – MPI parameters (comm, task …). If not specified, comm = domain.task_comm, task = domain.curent_task()

  • backend (Backend or ~hysop.core.arrays.ArrayBackend, optional) – Backend or backend kind for this topology. By default a topology will use Backend.HOST.

  • cart_dim (int, optional) – MPI topology dimension.

  • cart_shape (list or array of int, optional) – MPI grid layout, should be sized as the domain dimension.

  • is_periodic (tuple, list or array of bool, optional) – MPI grid periodicity, overrides discretization boundary conditions.

  • cutdirs (list or array of bool, optional) – Set which directions may be distributed, cutdirs[dir] = True allow MPI to distribute data along dir.

  • mesh (CartesianMesh, optional) – A predifined mesh (it includes local and global grids.)

  • cartesian_topology (Cartcomm, optional) – A predefined mpi cartesian topology. Use this when you need the same communicator for two different meshes/space distribution of data.

  • kwds (dict) – Base class arguments. Includes allocator, cl_env and queue.

global_resolution

Resolution of the global mesh (as given in the discretization parameter).

Type:

np.ndarray of HYSOP_INTEGER

ghosts

CartesianDiscretization ghosts of local-to-process mesh (as given in the discretization parameter).

Type:

np.ndarray of HYSOP_INTEGER

mesh

Local mesh on the current mpi process.

Type:

CartesianMeshView:

cart_comm

MPI cartesian topology intracommunicator.

Type:

Cartcomm

cart_dim

MPI_Cart topology dimension. Dimension of the MPI cartesian communicator. This dimension may be smaller than the domain dimension, because some directions may not be distributed.

Type:

int

cart_size

MPI_Cart grid size. Size of the MPI cartesian communicator (total number of MPI processes).

Type:

int

cart_rank

MPI_Cart rank. Rank of the current process in the cartesian communicator. May be different than self.mpi_params.rank.

Type:

int

cart_coords

Coordinate of this process in the cartesian communicator grid. The returned tuple is of dimension self.dimension.

Type:

np.ndarray of np.int32

cart_shape

MPI_Cart grid shape. Shape of the MPI cartesian communicator.

Type:

np.ndarray of np.int32

cart_periods

MPI_Cart grid periodicity

Type:

np.ndarray of bool

cart_ranks

Return all ranks of this cartesian topology as a np.ndarray such that array[cart_coords] = rank.

Type:

np.ndarray of np.int32

cart_ranks_mapping

Return all ranks of the parent MPI communicator as a np.ndarray such that array[cart_coords] = parent rank.

Type:

np.ndarray of np.int32

cart_neighbour_ranks

Return the ranks of the neighbours nodes as obtained by MPI_Cart_shift. self.neighbours[0,i] (resp. [1,i]) is the previous (resp. next) neighbour in direction i.

Type:

np.ndarray

proc_coords

Coordinates of this process in the extended cartesian grid (ie. with non distributed directions included). The returned tuple is of dimension self.domain_dim.

Type:

tuple of int

proc_shape

Processus grid shape, same as cart_shape but extended with non distributed directions.

Type:

tuple of int

proc_ranks

Return all ranks of this cartesian topology as a np.ndarray such that array[proc_coords] = rank.

Type:

np.ndarray of np.int32

proc_ranks_mapping

Return all ranks of the parent MPI communicator as a np.ndarray such that array[proc_coords] = parent rank.

Type:

np.ndarray of np.int32

proc_neighbour_ranks

Return the ranks of the neighbours nodes as obtained by MPI_Cart_shift. self.neighbours[0,i] (resp. [1,i]) is the previous (resp. next) neighbour in axe i. If axe is not distributed, self.neighbours[:,i] returns [-1,-1].

Type:

np.ndarray

is_distributed

Directions which have been distributed, is_distributed[dir] = True means that data has been distributed along dir.

Type:

tuple of bool

is_periodic

MPI grid periodicity. is_periodic[dir] = True means that the MPI grid is periodic along dir. /!This is not equivalent to domain periodicity, as a periodic

direction might not be distributed in the MPI cartesian grid or might be forced to be periodic for other reasons through the is_periodic parameter override. Domain periodicity is self.domain.periodicity

Type:

tuple of bool

Notes
------
\* Almost all parameters above are optional.

Only one must be chosen among dim, cutdirs and shape. See MPI topologies and space discretisation in the Hysop User Guide for details.

\* When cartesian_topology is given, dim, shape and cutdirs parameters,

if set, are not used to build the mpi topology, but compared with cartesian_topology parameters. If they do not fit, error is raised.

\* Unless is_periodic is specified periodicity is extracted

from domain boundary conditions.

\* All attributes are read-only properties.
discretize(field)[source]

Discretize a continous field on this topology and return a DiscreteField.

topology_like(backend=None, grid_resolution=None, ghosts=None, lboundaries=None, rboundaries=None, mpi_params=None, cart_shape=None, **kwds)[source]

Return a topology like this object, possibly altered.

view(topology_state)[source]

Returns a view of this topology with the given state.

class hysop.Domain(dim, parent_comm=None, proc_tasks=None, **kwds)[source]

Bases: RegisteredObject

Abstract base class for the description of physical domains.

Initialize this object. If self._initialized was already set to True, raise a RuntimeError. Else, set self._initialized to True.

static __new__(cls, dim, parent_comm=None, proc_tasks=None, **kwds)[source]

Create or get an existing physical domain of given dim on a specified MPI communicator and specific tasks.

Parameters:
  • dim (integer, optional) – dim of the domain.

  • parent_comm (MPI.Intracomm, optional) – Parent communicator which may be split. If not given this will be hysop.core.mpi.main_comm.

  • proc_tasks (tuple of ints or tuples of int, optional) – Mapping between mpi process rank and task identifier. If not given all procs will be on task HYSOP_DEFAULT_TASK_ID.

dim

Dimension of the domain.

Type:

int

proc_tasks

Mapping between mpi process rank and task identifier.

Type:

tuple of ints or tuples of int

parent_comm

Return the parent communicator used to create this domain.

Type:

MPI.Intracomm

parent_rank

Return the rank of the process in the parent communicator.

Type:

int

task_comm

Return the communicator that owns the current process. This is the sub-communicator which has been obtained by splitting the parent communicator by colors (proc_tasks).

Type:

MPI.IntraComm

task_rank

Return the rank of the process in the task communicator.

Type:

int

registered_topologies

Dictionary of all topologies already built on this domain with topology ids as keys and Topology as values.

Type:

dict

Notes

*Parent communicator is split/subgrouped according to proc_tasks. *About MPI Tasks

proc_tasks[n] = 12 means that task 12 owns proc n

or equivalently that proc n is dedicated to task 12.

proc_tasks[n] = (12, 13) means that proc n is dedicated to both tasks 12 and 13.

*Examples of supported mapping:
  • None or [1,1,1,1] : Single task (nothing more to do)

  • [1,2,2,2] : disjoint tasks (two task_comm created by Comm_Split and one intercommunicator for each other task)

  • [(1,2), (1,2), (2,), (2,)] : nested tasks (use the largest task intracommunicator as inter-task communication)

  • [(1,), (1,2), (2,), (2,)] : non zero intersection (Not handled yet)

  • [(1,2), (1,), (2,), (2,)] : non zero intersection with same leader (Not handled yet)

*A dupped parent_comm will return another idenpendent domain instance,

because MPI communicators are hashed trough their python object id.

register_topology(topo)[source]

Register a new topology on this domain. Do nothing if an equivalent topology is already in the list.

remove_topology(topo)[source]

Remove a topology from the list of this domain. Do nothing if the topology does not exist in the list.

abstract view(topology_state)[source]

Return a view of this domain altered by some topology_state.

hysop.Field

alias of FieldContainerI

class hysop.IO[source]

Bases: object

Static class with utilities to set/find the place where i/o files will be read/written.

ASCII = 997

ascii format id

HDF5 = 998

HDF5 format id

static cache_path()[source]
static check_dir(filepath, io_rank=0, comm=None)[source]

Check if the directory of ‘filename’ exists and creates it if not.

Parameters:
  • filepath (string) – directory path with full or relative path

  • io_rank (int) – processus rank that does the check.

  • comm (mpi communicator) – the mpi communicator that does the check.

classmethod default_cache_path()[source]
classmethod default_path()[source]

Get the current default path used for io.

Returns:

the default value of the current i/o path.

Return type:

string

classmethod default_ram_path()[source]

Get the current default path used for io in memory.

Returns:

the default value of the current RAM i/o path.

Return type:

string

static get_datasetnames(filename)[source]

Return the list of dataset names present in hdf input file

Parameters:

filename (string) – hdf file

Return type:

a list of strings

static get_fs_type(path)[source]
classmethod get_tmp_dir(key)[source]

Create or get an existing temporary directory.

classmethod is_shared_fs(path)[source]
classmethod ram_path()[source]
classmethod set_cache_path(path)[source]
static set_datasetname(field_name, topo, direction=None)[source]

Return the dataset name of a given continuous field, saved for a given topology

static set_default_path(pathdir)[source]

Set a new default path for hysop i/o.

Parameters:

pathdir (string) – the new path

class hysop.IOParams(filename, filepath=None, frequency=1, fileformat=None, dump_times=None, dump_tstart=None, dump_tend=None, dump_func=None, io_leader=0, visu_leader=0, with_last=False, enable_ram_fs=False, force_ram_fs=False, dump_is_temporary=False, postprocess_dump=None, hdf5_disable_compression=False, hdf5_disable_slicing=False, append=False, **kwds)[source]

Bases: IOParams

A struct to handle I/O files parameters

Parameters:
  • filename (string) – Name of the file (absolute or relative path)

  • filepath (string) – Location of the file

  • frequency (int) – Frequency of output or input (e.g. every N times steps)

  • fileformat (int) – Format of the file. See notes for available format. Default=HDF5.

  • dump_times (tuple of floats) – Extra dump times that should be used to dump in addition to frequency (double precision)

  • dump_tstart (float) – Start to dump at given time. Defaults to -np.inf (no time constraints).

  • dump_tend (float) – Stop to dump at given time. Defaults to +np.inf (no time constraints).

  • dump_func (function) – Generic function to compute the should_dump result.

  • with_last (boolean) – should dump when iteration is last one

  • io_leader (int) – Rank of the mpi process dealing with the io. Default is 0.

  • visu_leader (int) – Rank of the mpi process dealing with the graphical io. Default is 0.

  • enable_ram_fs (bool) – Instruct the dumper to write directly to RAM, fallback to filepath/filename when this is not possible.

  • force_ram_fs (bool) – Force the dumper to write directly to RAM, and raise an error when this is not possible (filepath/filename are ignored). Implies enable_ram_fs.

  • dump_is_temporary (bool) – Instruct the dumper to delete dumped data from disk or RAM after postprocessing script has been called. Implies that a postprocessing script is supplied.

  • postprocess_dump (str) – Path to a postprocessing script that will be called after dump. See hysop/tools/postprocess_dump.sh for an example of post processing script.

  • hdf5_disable_compression (bool) – Disable compression for HDF5 outputs (when available). Can be used to accelerate in RAM postprocessing.

  • hdf5_disable_slicing (bool) – Disable slicing for HDF5 outputs (when available). May reduce performance but avoid hdf5 file fragmentation.

  • append (bool, optional) – Tell if appended (on xmf files, when using hdf format)

  • kwds (dict) – Custom extra keyword arguments to pass to operators

  • hysop.operator.hdf_io (See examples in)

Notes

Format parameter must be one of the following :

Create new instance of IOParams(filename, filepath, frequency, fileformat, dump_times_fp32, dump_times_fp64, dump_tstart, dump_tend, dump_func, io_leader, visu_leader, with_last, enable_ram_fs, force_ram_fs, dump_is_temporary, postprocess_dump, append, hdf5_disable_compression, hdf5_disable_slicing, disk_filepath, kwds)

clone(**kwds)[source]
property dump_times
should_dump(simulation)[source]
to_string(prefix='')[source]
class hysop.MPIParams(comm=<mpi4py.MPI.Intracomm object>, task_id=999, rank=0, on_task=True)[source]

Bases: MPIParams

Struct to save mpi parameters : - comm : parent mpi communicator (default = main_comm) - task_id : id of the task that owns this object (default = HYSOP_DEFAULT_TASK_ID) - rank of the current process in comm - on_task : true if the task_id of the object corresponds to the task_id of the current process.

This struct is useful for operators : each operator has a MPIParams attribute to save its mpi settings.

Examples

op = SomeOperator(…, task_id=1) if op.is_on_task():

‘is_on_task’ will return MPIParams.on_task value for op and tell if the current operator belongs to the current process mpi task.

Create new instance of MPIParams(comm, size, task_id, rank, on_task)

diff(other)[source]
class hysop.Problem(name=None, method=None, mpi_params=None, check_unique_clenv=True, **kwds)[source]

Bases: ComputationalGraph

Parameters:

kwds (arguments for base classes.)

Notes

The following base class variables cannot be specified during graph construction:

variables, input_variables, output_variables

Order of operation is: add_node, initialize, discretize,

get_work_properties, setup, apply, finalize.

Nodes can also be added during pre initialization step. Graph building is done at the end of the initialization step, after all internal nodes have been initialized.

build(args=None, allow_subbuffers=False, outputs_are_inputs=True, search_intertasks_ops=None)[source]

Shortcut for initialize(), discretize(), get_work_properties(), setup() for quick graph initialization.

build_problem(args, allow_subbuffers, outputs_are_inputs=True, search_intertasks_ops=None)[source]
check_unique_clenv()[source]
discretize()[source]

Discretize this operator. By default this just sets the self.discretized flag to True. Once this flag is set one may call ComputationalGraphNode.get_work_properties() and ComputationalGraphNode.setup().

final_report()[source]
finalize()[source]

Cleanup this node (free memory from external solvers, …) By default, this does nothing

get_preserved_input_fields()[source]
initialize_field(field, mpi_params=None, **kwds)[source]

Initialize a field on all its input and output topologies.

insert(*ops)[source]
solve(simu, dry_run=False, dbg=None, report_freq=10, plot_freq=10, checkpoint_handler=None, **kwds)[source]
class hysop.ScalarParameter(name, **kwds)[source]

Bases: TensorParameter

A scalar parameter is TensorParameter with its shape set to (1,). A parameter is a value that may change as simulation advances.

Initialize a TaggedObject with a tag prefix/postfix/formatter, all optional.

__complex__()[source]

Return value as a complex.

__float__()[source]

Return value as a float.

__int__()[source]

Return value as an int.

iterviews()[source]

Iterate over all parameters views to yield scalarparameters.

long_description()[source]

Return a long description of this parameter as a string.

short_description()[source]

Return a short description of this parameter as a string.

class hysop.Simulation(name=None, start=0.0, end=1.0, nb_iter=None, dt0=None, max_iter=None, t=None, dt=None, times_of_interest=None, mpi_params=None, quiet=False, clamp_t_to_end=True, restart=0, **kwds)[source]

Bases: object

Time-Simulation process description (time step, iteration …)

Parameters:
  • name (str, optional) – Name of this simulation.

  • start (real, optional) – Initial and final time for simulation.

  • end (real, optional) – Initial and final time for simulation.

  • nb_iter (int, optional) – Number of iterations required.

  • dt0 (real, optional) – Initial time step.

  • dt (ScalarParameter, optional) – ScalarParameter that will be used as time step. Cannot be a constant parameter.

  • t (ScalarParameter, optional) – ScalarParameter that will be used as time. Cannot be a constant parameter.

  • max_iter (int, optional) – Maximum number of iterations allowed. Defaults to 1e9.

  • times_of_interest (array-like of float) – List of times ti where the simulation may modify current timestep to get t=ti. Mainly used by HDF_Writers for precise time dependent dumping. tstart < ti <= tend Defaults to empty set.

  • clamp_t_to_end (bool, optional) – Specify if Simulation adjst dt for last iteration to have t=end

  • restart (int, optional) – Iteration number to start from.

time

current time (value at the end of the time step)

Type:

real

current_iteration

start at 0. See notes below.

Type:

int

is_over

true if end or max_iter or nb_iter has been reached.

Type:

bool

dt

The scalar parameter that may be updated.

Type:

hysop.parameter.scalar_parameter.ScalarParameter

t

The scalar parameter that represents time.

Type:

hysop.parameter.scalar_parameter.ScalarParameter

time_step

Value of the dt parameter.

Type:

double

time_of_interest

Current simulation time target.

Type:

float

Notes

  • all parameters are optional but either dt0 or nb_iter must be set.

  • If both dt0 and nb_iter are given, dt0 is not used.

  • current_iteration = -1 means simulation has not started, and self.time = self.start

  • current_iteration = 0 after a call to initialize, self.time = self.start + self.time_step, i.e. targeted time.

  • self.current_iteration = k, runs between self.t and self.tkp1. with self.tkp1 == self.time

advance(dbg=None, plot_freq=10)[source]

Proceed to next time.

  • Advance time and iteration number.

  • Compute the new timestep

  • check if simulation is over.

finalize()[source]

Use this function when you need to call an hdf i/o operator after the end of the time-loop.

initialize()[source]

(Re)set simulation to initial values –> back to iteration 0 and ready to run.

load_checkpoint(datagroup, mpi_params, io_params, relax_constraints)[source]
next_time_of_interest()[source]
print_state(verbose=None)[source]

Print current simulation parameters

save_checkpoint(datagroup, mpi_params, io_params, compressor)[source]
property time_step

Get current timestep.

update_time(t)[source]
update_time_step(dt)[source]

Update time step for the next iteration

Parameters:

dt (double) – the new time step

Notes

Warning : since it does not update tkp1 and time, it must be called at the end of the time loop, just before ‘advance’.

write_parameters(*params, **kwds)[source]
class hysop.TensorParameter(name, shape, dtype=<class 'numpy.float64'>, pretty_name=None, initial_value=None, min_value=None, max_value=None, ignore_nans=False, **kwds)[source]

Bases: Parameter

A tensor parameter is np.ndarray of a given dtype and shape that may change value as simulation advances.

Initialize a TaggedObject with a tag prefix/postfix/formatter, all optional.

__getitem__(slices)[source]

Get a read-only subview on this array parameter.

static __new__(cls, name, shape, dtype=<class 'numpy.float64'>, pretty_name=None, initial_value=None, min_value=None, max_value=None, ignore_nans=False, **kwds)[source]

Create or get an existing TensorParameter with a specific name shape and dtype.

Parameters:
  • name (string) – A name for the parameter that uniquely identifies it.

  • pretty_name (string) – A pretty name for the parameter.

  • shape (array like of ints) – Shape of this TensorParameter.

  • dtype (type convertible to np.dtype, optional) – Underlying dtype of this TensorParameter. Defaults to HYSOP_REAL.

  • initial_value (optional, defaults to an uninitialized array.) – Initial value as a scalar or np.ndarray. If not initial value is given, all values initialized to 0.

  • min_value (scalar, optional, defaults to None) – Minimum value allowed for this parameter.

  • max_value (scalar, optional, defaults to None) – Maximum value allowed for this parameter.

  • ignore_nans (bool) – Set this to True to allow NaN values.

  • kwds (dict) – Base class arguments.

shape

Shape of this TensorParameter.

Type:

array like of ints

dtype

Underlying dtype of this TensorParameter.

Type:

type convertible to np.dtype

min_value

Minimum value allowed for this TensorParameter.

Type:

scalar, optional, defaults to None

max_value

Maximum value allowed for this TensorParameter.

Type:

scalar, optional, defaults to None

ignore_nans

True if this TensorParameter can have NaN values.

Type:

bool

__setitem__(slices, value)[source]

Set a subview on this array parameter to a certain value (value can be broadcasted).

check_values(a)[source]
property ctype

Get the data type of the discrete field as a C type.

property dtype

Get parameter dtype.

property ignore_nans

Return True if array can have NaNs.

iterviews()[source]

Iterate over all parameters views to yield scalarparameters.

long_description()[source]

Return a long description of this parameter as a string.

property max_value

Return maximum value allowed for array values.

property min_value

Return minimum value allowed for array values.

reallocate_tensor(shape, dtype, initial_value=None)[source]
property shape

Get parameter shape.

short_description()[source]

Return a short description of this parameter as a string.

property size

Get parameter size.

property tensor_value

Get a read-only view on this array parameter but always as a numpy array, even for ScalarParameter parameters.

view(idx, name=None, pretty_name=None, **kwds)[source]

Take a view on a scalar contained in the Parameter.

class hysop.Topology(domain, mpi_params=None, backend=HOST(1), cl_env=None, allocator=None, queue=None, **kwds)[source]

Bases: RegisteredObject

Abstract base class for hysop Topologies.

In hysop, a topology is defined as the association of a mpi process distribution (mpi topology) and of a set of local meshes (one per process).

At the time, only CartesianTopology topologies with cartesian meshes are available.

For details about topologies see HySoP User Manual. You can also find examples of topologies instanciation in test_topology.py.

Initialize this object. If self._initialized was already set to True, raise a RuntimeError. Else, set self._initialized to True.

static __new__(cls, domain, mpi_params=None, backend=HOST(1), cl_env=None, allocator=None, queue=None, **kwds)[source]

Creates or get an existing topology.

Parameters:
  • domain (Domain) – the geometry on which the topology is defined.

  • mpi_params (MPIParams, optional) – MPI parameters (comm, task …). If not specified, comm = domain.task_comm, task = domain.curent_task()

  • backend (Backend or ~hysop.core.arrays.ArrayBackend, optional) – Backend or backend kind for this topology. By default a topology will use Backend.HOST.

  • allocator (Allocator, optional) – Allocated used on HOST backends instead of the default host memory pool allocator. Only used if the backend is Backend.HOST.

  • cl_env (OpenClEnvironment, optional) – Topology will use this specified OpenClEnvironment when backend is Backend.OPENCL. By default a new environment is created with get_or_create_opencl_env(mpi_params.comm)

  • queue (pyopencl.Queue, optional) – Default queue used for OpenCL Arrays. By default this queue will be cl_env.default_queue. Only used if the backend is Backend.OPENCL.

  • kwds (dict) – Base class keyword arguments.

  • Notes

  • ------

  • RegisteredObjects. (Topologies can be uniquely identified by their id as they are hysop)

:param See RegisteredObject for more information.:

abstract discretize(field)[source]

Discretize a continous field on this topology and return a DiscreteField.

abstract view(topology_state)[source]

Return a TopologyView of this topology with a specific state.

class hysop.TopologyDescriptor(mpi_params, domain, backend, **kwds)[source]

Bases: object

Describes how a topology should be built.

Multiple compatible topology descriptors are gathered during operator graph building and are replaced by a single unique topology upon initialization.

Initialize a TopologyDescriptor.

Notes

kwds allows for backend specific variables. CartesianTopologyDescriptor is immutable.

property backend

Get backend.

static build_descriptor(backend, operator, field, handle, **kwds)[source]

Generate a descriptor from a lower level representation. If handle is already a Topology or a TopologyDescriptor it is returned unchanged.

If handle is a CartesianTopologyDescriptors (ie. currently a Discretization), a CartesianTopologyDescriptor is created and returned.

Every new topology type should be registered here.

choose_or_create_topology(known_topologies, **kwds)[source]

Returns a topology that is either taken from known_topologies, a set of user specified topologies which are ensured to be compatible with the current TopologyDescriptor, or created from the descriptor if choose_topology() returns None.

abstract choose_topology(known_topologies, **kwds)[source]

Find optimal topology parameters from known_topologies. If None is returned, create_topology will be called instead.

abstract create_topology(**kwds)[source]

Build a topology with the current TopologyDescriptor.

property dim

Get domain dimension.

property domain

Get domain.

property extra_kwds

Get extra keyword arguments.

match(other, invert=False)[source]

Test if this descriptor is equivalent to the other one.

property mpi_params

Get mpi parameters.

Subpackages

Submodules